#include <iostream>
#include <unistd.h>
#include <cstring>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
using namespace std;
int main()
{
    int flag = 1;
    int sock = socket(AF_INET, SOCK_DGRAM, 0);
    sockaddr_in serve;
    serve.sin_port = htons(8080);
    serve.sin_addr.s_addr = inet_addr("127.0.0.1");
    serve.sin_family = AF_INET;
    char buffer[40960];
    memset(buffer, 'c', 40960);
    int nread;
    while (true)
    {
        ioctl(sock, FIONREAD, &nread);
        if (flag == 1)
        {
            flag--;
            sendto(sock, buffer, sizeof(buffer), 0, (sockaddr *)(&serve), sizeof(serve));
        }
        if (errno == ENOBUFS)
            cout << "满了" << endl;
    }
    return 0;
}